/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2010 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _ERRORDIRECTDRAW_H_
#define _ERRORDIRECTDRAW_H_

#include "YoghurtGum.h"
#include "YGError.h"

namespace YoghurtGum
{

	struct ErrorDirectDraw
	{

		static bool Failed(Flag a_Status)
		{
			if (FAILED(a_Status)) { Check(a_Status); return true; }
			return false;
		}

		static void Check(Flag a_Flag)
		{
			if (!Error::BaseCheck(a_Flag))
			{
				switch (a_Flag)
				{
				case DDERR_GENERIC:
					Log::GetSingleton() << "ERROR! DirectDraw: Generic error. (DDERR_GENERIC)" << ENDL; 
					break;	
				case DDERR_OUTOFMEMORY:	
					Log::GetSingleton() << "ERROR! DirectDraw: Out of memory. (DDERR_OUTOFMEMORY)" << ENDL;
					break;
				
				case DDERR_NOTFOUND:
					Log::GetSingleton() << "ERROR! DirectDraw: The requested item was not found. (DDERR_NOTFOUND)" << ENDL; 
					break;
				case DDERR_INVALIDCLIPLIST:
					Log::GetSingleton() << "ERROR! DirectDraw: Invalid clip list. (DDERR_INVALIDCLIPLIST)" << ENDL; 
					break;
				case DDERR_INVALIDRECT:
					Log::GetSingleton() << "ERROR! DirectDraw: Invalid RECT coordinates. (DDERR_INVALIDRECT)" << ENDL; 
					break;
				case DDERR_NOCLIPLIST:
					Log::GetSingleton() << "ERROR! DirectDraw: No clip list is available. (DDERR_NOCLIPLIST)" << ENDL; 
					break;
				case DDERR_NOALPHAHW:
					Log::GetSingleton() << "ERROR! DirectDraw: Hardware does not support alpha blending. (DDERR_NOALPHAHW)" << ENDL; 
					break;
				case DDERR_NOBLTHW:
					Log::GetSingleton() << "ERROR! DirectDraw: Hardware does not support blitting. (DDERR_NOBLTHW)" << ENDL; 
					break;
				case DDERR_PRIMARYSURFACEALREADYEXISTS:
					Log::GetSingleton() << "ERROR! DirectDraw: Primary surface already exists. (DDERR_PRIMARYSURFACEALREADYEXISTS)" << ENDL; 
					break;
				case DDERR_NORASTEROPHW:
					Log::GetSingleton() << "ERROR! DirectDraw: Hardware does not support raster operations. (DDERR_NORASTEROPHW)" << ENDL; 
					break;
				case DDERR_NOSTRETCHHW:
					Log::GetSingleton() << "ERROR! DirectDraw: Hardware does not support surface stretching. (DDERR_NOSTRETCHHW)" << ENDL; 
					break;
				case DDERR_NOFLIPHW:
					Log::GetSingleton() << "ERROR! DirectDraw: Hardware does not support surface flipping. (DDERR_NOFLIPHW)" << ENDL; 
					break;	
				case DDERR_INVALIDMODE:
					Log::GetSingleton() << "ERROR! DirectDraw: The requested mode is not supported. (DDERR_INVALIDMODE)" << ENDL; 
					break;
				case DDERR_INVALIDOBJECT:
					Log::GetSingleton() << "ERROR! DirectDraw: The supplied pointer is not a valid DirectDraw object. (DDERR_INVALIDOBJECT)" << ENDL; 
					break;
				case DDERR_INVALIDPARAMS:
					Log::GetSingleton() << "ERROR! DirectDraw: One or more of the passed parameters are incorrect. (DDERR_INVALIDPARAMS)" << ENDL; 
					break;
				case DDERR_LOCKEDSURFACES:
					Log::GetSingleton() << "ERROR! DirectDraw: The target surface is locked. (DDERR_LOCKEDSURFACES)" << ENDL; 
					break;
				case DDERR_SURFACEBUSY:
					Log::GetSingleton() << "ERROR! DirectDraw: The surface was locked in another thread. (DDERR_SURFACEBUSY)" << ENDL; 
					break;
				case DDERR_SURFACELOST:
					Log::GetSingleton() << "ERROR! DirectDraw: The target surface's memory is no longer available. (DDERR_SURFACELOST)" << ENDL; 
					break;
				case DDERR_UNSUPPORTED:
					Log::GetSingleton() << "ERROR! DirectDraw: Unsupported operation. (DDERR_UNSUPPORTED)" << ENDL; 
					break;
				case DDERR_WASSTILLDRAWING:
					Log::GetSingleton() << "ERROR! DirectDraw: The previous blitter operation was still busy. (DDERR_WASSTILLDRAWING)" << ENDL; 
					break;
				case DDERR_NOCOOPERATIVELEVELSET:
					Log::GetSingleton() << "ERROR! DirectDraw: The program doesn't know whether it's in a window or fullscreen. (DDERR_NOCOOPERATIVELEVELSET)" << ENDL; 
					break;
				case DDERR_INVALIDCAPS:
					Log::GetSingleton() << "ERROR! DirectDraw: One or more of the caps bits passed to the callback are incorrect. (DDERR_INVALIDCAPS)" << ENDL;
					break;

				default:
					Error::DefaultError(a_Flag);
				}
			}
		}
		
	}; // struct ErrorDirectDraw

}; // namespace YoghurtGum

#endif